package com.sise.selector;

import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.Set;

public class SelectorDemo2 {

    public static void main(String[] args) throws IOException {
        Selector selector = Selector.open();
        SocketChannel socketChannel = SocketChannel.open();
        SelectionKey selectionKey = socketChannel.register(selector, SelectionKey.OP_READ);
        while (true) {
            int readChannel = selector.select();
            if (readChannel == 0) {
                continue;
            }
            Set<SelectionKey> selectedKeys = selector.selectedKeys();
            for (SelectionKey selectedKey : selectedKeys) {
                if (selectedKey.isReadable()) {

                } else if (selectedKey.isWritable()) {

                } else if (selectedKey.isValid()) {

                } else if (selectedKey.isReadable()) {

                } else if (selectedKey.isConnectable()) {

                }
            }
        }
    }
}
